package com.software.seakdream.controller;

import com.software.seakdream.domain.Result;
import com.software.seakdream.entity.*;
import com.software.seakdream.service.WhiteNoiseService;
import com.software.seakdream.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 对白噪音的操作都在这里，包括对白噪音历史记录的操作
 */
@RestController
@RequestMapping("/WhiteNoise")
public class WhiteNoiseController {
    @Autowired
    private WhiteNoiseService whiteNoiseService;
    @GetMapping("/FreeConbination/findAllFreeConbination/{type}")
    public List<AudioInfo> findAllFreeConbination(@PathVariable String type){
        List<AudioInfo> audioInfos = whiteNoiseService.findAllFreeConbination(type);
        return audioInfos;
    }

    @GetMapping("/FreeConbination/findFreeConbinationById/{selectedId1}/{selectedId2}/{selectedId3}")
    public List<AudioInfo> findFreeConbinationById(@PathVariable String selectedId1,@PathVariable String selectedId2,@PathVariable String selectedId3){
        List<AudioInfo> audioInfos = whiteNoiseService.findFreeConbinationById(selectedId1,selectedId2,selectedId3);
        return audioInfos;
    }

    @GetMapping("/SleepFriendCreation/findAllSleepFriendCreation")
    public List<SleepFriendCreation> findAllSleepFriendCreation(){
        List<SleepFriendCreation> sleepFriendCreations = whiteNoiseService.findAllSleepFriendCreation();
        return  sleepFriendCreations;
    }
    @GetMapping("/SleepFriendCreation/findAllUser")
    public List<UserInfo> findAllUser(){
        List<UserInfo> userInfos = whiteNoiseService.findAllUser();
        return  userInfos;
    }
    @GetMapping("/SleepFriendCreation/findUserInfoById/{userId}")
    public UserInfo findUserInfoById(@PathVariable String userId){
        UserInfo userInfo = whiteNoiseService.findUserInfoById(userId);
        return  userInfo;
    }

    @GetMapping("/OfficialRecommendation/findAllOfficialRecommendation")
    public List<OfficialRecommendation>  findAllOfficialRecommendation(){
        List<OfficialRecommendation> officialRecommendations = whiteNoiseService.findAllOfficialRecommendation();
        return  officialRecommendations;
    }

    @PostMapping("/VoiceDescribe/addSleepFriendCreation")
    public String addSleepFriendCreation(SleepFriendCreation sleepFriendCreation){
        String ok = whiteNoiseService.addSleepFriendCreation(sleepFriendCreation);

        return ok;

    }


    @GetMapping("/VoiceRemark/findVoiceRemarkBySleepId/{sleepFriendId}")
    public List<VoiceRemark> findVoiceRemarkBySleepId(@PathVariable String sleepFriendId){
        List<VoiceRemark> voiceRemarks = whiteNoiseService.findVoiceRemarkBySleepId(sleepFriendId);
        return voiceRemarks;
    }

    @PostMapping("/VoiceRemark/addVoiceRemark")
    public String addVoiceRemark(VoiceRemark voiceRemark){
        String ok = whiteNoiseService.addVoiceRemark(voiceRemark);
        return ok;

    }
    @PostMapping("/createHistory")
    public Result createHistory(History history){
        whiteNoiseService.createHistory(history);
        return ResultUtils.success(null);
    }

    @PostMapping("/deleteHistory")
    public Result deleteHistory(History history){
        whiteNoiseService.deleteHistory(history);
        return ResultUtils.success(null);
    }



}
